import request from '@/router/axios';

/**
 * 分页查询标签条码列表
 * @param {*} current
 * @param {*} size
 * @param {*} params
 * @returns
 */
export const getList = (current, size, params) => {
  return request({
    url: '/api/mes-admin/sequence/generation/page/sequencenumber-or-sourcetype',
    method: 'get',
    params: {
      current,
      size,
      ...params
    }
  });
};

/**
 * 获取条码详情
 * @param {*} id
 * @returns
 */
export const getDetail = (id) => {
  return request({
    url: '/api/mes-admin/sequence/generation/detail-by-id',
    method: 'get',
    params: {
      id
    }
  });
};

export const getPackingDetail = (current, size, params) => {
  return request({
    url: '/api/mes-admin/sequence/generation/sn',
    method: 'get',
    params: {
      current,
      size,
      ...params
    }
  });
};

export const getProductDetail = (current, size, params) => {
  return request({
    url: '/api/mes-product/product/detail-by-id',
    method: 'get',
    params: {
      current,
      size,
      ...params
    }
  });
};

export const getLabelDetail = (current, size, params) => {
  return request({
    url: '/api/mes-admin/sequence/generation/sn-list',
    method: 'get',
    params: {
      current,
      size,
      ...params
    }
  });
};
/**
 * 原材俩-采购单条码打印
 * @param {*} data
 * @returns
 */
export const materialPrint = (data) => {
  return request({
    url: '/api/mes-warehouse/packing/generation/pack/print',
    method: 'post',
    data: data
  });
};

/**
 * 原材俩-其他条码打印
 * @param {*} data
 * @returns
 */
export const materialOtherPrint = (data) => {
  return request({
    url: '/api/mes-warehouse/packing/generation/sequence/part-master/print',
    method: 'post',
    data: data
  });
};

/**
 * 产品序列号打印
 * @param {*} data
 * @returns
 */
export const snPrint = (data) => {
  return request({
    url: '/api/mes-admin/label-product/sequence/rePrint',
    method: 'post',
    data: data
  });
};

export const finishSnPrint = (data) => {
  return request({
    url: 'api/mes-admin/label-finished/sequence/print',
    method: 'post',
    data: data
  });
};
export const warehouseSnPrint = (data) => {
  return request({
    url: 'api/mes-admin/label-finished/sequence/duplicate-print',
    method: 'post',
    data: data
  });
};

/**
 * 成品包装条码打印及原材料包装条码打印
 * @param {*} data
 * @returns
 */
export const packPrint = (data) => {
  return request({
    url: '/api/mes-admin/label-material/sequence/duplicate-print',
    method: 'post',
    data: data
  });
};

/**
 * 产品序列号报废
 */
export const sequenceScrap = (data) => {
  return request({
    url: '/api/mes-admin/label-product/sequence/scrap',
    method: 'post',
    data: data
  });
};
/**
 * 包装报废
 */
export const packingScrap = (data) => {
  return request({
    url: '/api/mes-warehouse/packing/generation/scrap-product-pack',
    method: 'post',
    data: data
  });
};

/**
 * 原材料包装条码产品序列号报废
 */
export const matrialSequenceScrap = (data) => {
  return request({
    url: '/api/mes-warehouse/sheetheader/scrap-raw-material-packaging-barcode',
    method: 'post',
    data: data
  });
};

/**
 * 原材料标签置换
 * @param {*} id
 * @returns
 */
export const materialSequenceReplace = (data) => {
  return request({
    url: '/api/mes-warehouse/packing/generation/replace',
    method: 'post',
    data: data
  });
};

/**
 * 产品序列号置换
 */
export const snSequenceReplace = (data) => {
  return request({
    url: '/api/mes-admin/label-product/replace',
    method: 'post',
    data: data
  });
};
//获取打印机配置
export const getPrinter = (id) => {
  return request({
    url: '/api/blade-system/user/get-print-labeltemplate',
    method: 'get',
    params: {
      ...id
    }
  });
};
//获取打印机配置
export const getLastPrint = (params) => {
  return request({
    url: '/api/mes-admin/label-print-config/get-print-config',
    method: 'POST',
    params: {
      ...params
    }
  });
};
//获取打印机配置
export const getLastPrintRecord = (params) => {
  return request({
    url: '/api/mes-admin/label-print-config/get-print-config',
    method: 'POST',
    params: {
      ...params,
      type: 'MATERIAL'
    }
  });
};
//获取打印机配置(条码重打)
export const getPrinterNew = (params) => {
  return request({
    url: '/api/mes-admin/label-print-config/get-print-config',
    method: 'POST',
    params: {
      ...params,
      type: 'MATERIAL'
    }
  });
};

/**
 * 产品序列号置换
 */
export const sequenceNumber = (sequenceNumber) => {
  return request({
    url: '/api/mes-admin/label-product/info-by-sequenceNumber',
    method: 'get',
    params: {
      sequenceNumber
    }
  });
};
/**
 * 成品包装置换
 */
export const packingCheck = (seq) => {
  return request({
    url: '/api/mes-warehouse/packing/check',
    method: 'get',
    params: {
      seq
    }
  });
};
export const getDetailorder = (id) => {
  return request({
    url: '/api/mes-product/work-order/detail',
    method: 'get',
    params: {
      id
    }
  });
};
export const queryWorkOrder = (params) => {
  return request({
    url: '/api/mes-product/workorder/query-work-order',
    method: 'post',
    params
  });
};
export const getDetailpack = (sequenceNumber) => {
  return request({
    url: '/api/mes-warehouse/packing/detail',
    method: 'get',
    params: {
      sequenceNumber
    }
  });
};

export const getPrintHistory = (generationId) => {
  return request({
    url: '/api/mes-admin/sequence/print/record/getLastPrintRecordByGenerationId',
    method: 'get',
    params: {
      generationId: generationId
    }
  });
};

// 仓库标签报废
export const warehouseScrap = (data) => {
  return request({
    url: '/api/mes-admin/label-material/sequence/scrap',
    method: 'post',
    data: data
  });
};

//成品标签报废
export const finishedScrap = (data) => {
  return request({
    url: '/api/mes-admin/label-finished/sequence/scrap',
    method: 'post',
    data: data
  });
};

// 仓库标签重打
export const warehousePrint = (data) => {
  return request({
    url: '/api/mes-admin/label-material/sequence/duplicate-print',
    method: 'post',
    data: data
  });
};

export const materialSnPrint = (row) => {
  return request({
    url: '/api/mes-admin/label-material/sequence/print',
    method: 'post',
    data: row
  });
};

//产品标签重打
export const productPrint = (data) => {
  return request({
    url: '/api/mes-admin/label-material/sequence/duplicate-print',
    method: 'post',
    data: data
  });
};

// 导出
export const productExport = (params) => {
  return request({
    url: '/api/mes-admin/sequence/generation/export-label-record-refactor',
    method: 'get',
    params: params,
    responseType: 'blob'
  });
};
// 仓库标签撤销
export const warehouseRevoke = (data) => {
  return request({
    url: '/api/mes-admin/label-material/sequence/revoke',
    method: 'post',
    data: data
  });
};

// 产品标签撤销
export const productRevoke = (data) => {
  return request({
    url: '/api/mes-product/workorder/generation/revoke',
    method: 'post',
    data: data
  });
};

export const inOutScrap = (data) => {
  return request({
    url: 'api/mes-admin/label-material/tree-pack/sequence-scrap',
    method: 'post',
    data: data
  });
};
